package com.zy.smarthome.config;

import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wjming
 * @ClassName: RabbitConfig
 * @Description: 建交换机, 队列, 并建立关系
 * @Date 2021/2/22 15:17
 */
@Configuration
public class RabbitConfig {
    @Value("${directExchange}")
    private String directExchange;

    @Value("${topic.rabbit.gatewayWriteChannel}")
    private String gatewayWriteChannel;

    @Value("${topic.rabbit.smartHomeFrameProcess}")
    private String smartHomeFrameProcess;

    @Value("${topic.ttl}")
    private Integer ttl;

    @Bean

    public Queue queueGatewayWrite() {
        Map<String, Object> arguments = new HashMap<>(1);
        arguments.put("x-message-ttl", ttl);
        return new Queue(gatewayWriteChannel, true, false, false, arguments);
    }

    @Bean
    public Queue smartHomeFrameProcess() {
        Map<String, Object> arguments = new HashMap<>(1);
        arguments.put("x-message-ttl", ttl);
        return new Queue(smartHomeFrameProcess, true, false, false, arguments);
    }
}
